package com.zjdiepu.www.commpent.mapper.yw;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.stereotype.Component;

import com.zjdiepu.www.base.core.BaseMapper;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.zx.response.ZxCreditQueryDetail;
/**
 * 项目名称：dpqc-parent-manager-information <br/> 
 * 类名称：ZxCrediQueryDetailMapper <br/>  
 * 类描述： 征信查询结果<br/>    
 * 创建人：xiongxiaotun <br/> 
 * 创建时间：2017年4月26日 下午1:33:37  <br/>   
 * 修改人：xiongxiaotun <br/> 
 * 修改时间：2017年4月26日 下午1:33:37   <br/>  
 * 修改备注：    <br/> 
 * @version V1.0   <br/>
 */
@Component
public class ZxCrediQueryDetailMapper extends BaseMapper<ZxCreditQueryDetail>{
	@Resource
	private RedisObjectClient redisObjectClient;

	@Override
	public void mapper(RedisConnection redisConnection,ZxCreditQueryDetail m) {
		if(null == m) {
			return;
		}
		
		String creditPeopleType = m.getCreditPeopleType();
		SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), creditPeopleType, DataDicType.CREDIT_PEOPLE_TYPE.getCode());
		m.setCreditPeopleTypeDisplay(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
		
		String creditResult = m.getCreditResult();
		SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), creditResult, DataDicType.CREDIT_RESULT.getCode());
		m.setCreditResultDisplay(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
		
		String onceCarStatuses_ = m.getOnceCarStatus();
		StringBuilder sb = new StringBuilder();
		if(StringUtils.isNotBlank(onceCarStatuses_)) {
			String[] onceCarStatuses = onceCarStatuses_.split(",");
			for(String onceCarStatus : onceCarStatuses) {
				if(StringUtils.isNotBlank(onceCarStatus)) {
					onceCarStatus = onceCarStatus.trim();
					SimpleDataDictionary simpleDataDictionary3 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), onceCarStatus, DataDicType.ONCE_CAR_STATUS.getCode());
					if(null != simpleDataDictionary3) {
						sb.append(simpleDataDictionary3.getName() + ",");
					}
				}
			}
		}
		String onceCarStatusDisplay = sb.toString();
		if(onceCarStatusDisplay.length() > 0) {
			onceCarStatusDisplay = onceCarStatusDisplay.substring(0, onceCarStatusDisplay.length() - 1);
		}
		m.setOnceCarStatusDisplay(onceCarStatusDisplay);
		
		String bankCode = m.getBankCode();
		SimpleDataDictionary simpleDataDictionary4 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), bankCode, DataDicType.LOAN_BANK.getCode());
		m.setBankCodeDisplay(simpleDataDictionary4 == null ? "" : simpleDataDictionary4.getName());
	}

}
